﻿using System;
using System.Data;
using CuoiHoi.Business;

namespace CuoiHoi
{
    public partial class MenuDoc : System.Web.UI.UserControl
    {
        public DataTable TbMenu;
        string idpage = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.RouteData.Values["TitleDanhMuc"] != null)
                idpage = Page.RouteData.Values["TitleDanhMuc"].ToString();
        }
        public void MenuDong(string idTheLoaiCha)
        {
            DataTable table = new DataTable();
            table = BTheLoai.SelectByidTheLoaiCha(idTheLoaiCha);
            int count = table.Rows.Count;

            if (count > 0 && idTheLoaiCha != "0")
                Response.Write("<span class='child-menu'>");
           
            for (int i = 0; i < count; i++)
            {
                if (idpage == Router.NonUnicode(table.Rows[i]["TenTheLoai"].ToString()))
                    Response.Write("<a rel='nofollow' class='list-group-item active' href='/" + Router.NonUnicode(table.Rows[i]["TenTheLoai"].ToString()) + "-" + table.Rows[i]["DuongDan"].ToString() + Router.NonUnicode(table.Rows[i]["idTheLoai"].ToString()) + "'>" + table.Rows[i]["TenTheLoai"].ToString() + "</a>");
                else
                    Response.Write("<a rel='nofollow' class='list-group-item' href='/" + Router.NonUnicode(table.Rows[i]["TenTheLoai"].ToString()) + "-" + table.Rows[i]["DuongDan"].ToString() + Router.NonUnicode(table.Rows[i]["idTheLoai"].ToString()) + "'>" + table.Rows[i]["TenTheLoai"].ToString() + "</a>");

                MenuDong(table.Rows[i]["idTheLoai"].ToString());
            }

            if (count > 0) Response.Write("</span>");
        }
    }
}